package com.xingying.travel.controller;


import com.xingying.travel.common.Result;
import com.xingying.travel.common.StatusCode;
import com.xingying.travel.pojo.Article;
import com.xingying.travel.pojo.Comment;
import com.xingying.travel.pojo.User;
import com.xingying.travel.service.ArticleService;
import com.xingying.travel.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;

@RestController
@CrossOrigin
@RequestMapping("/comment")
public class CommentController
{

    @Autowired
    private CommentService commentService;

    /**
     * 增加
     * @param comment
     */
    @RequestMapping(method= RequestMethod.POST)
    public Result add(@RequestBody  Comment comment, HttpSession session){
        User us= (User) session.getAttribute("user");
        comment.setCreateId(us.getId());
        comment.setCreateBy(us.getName());
        comment.setCreateTime(new Date());
        commentService.add(comment);
        return new Result(true, StatusCode.OK,"增加成功");
    }















}
